<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>新增面试</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
</head>
<body>
    <div th:replace="common/header :: header"></div>

    <div class="container mt-4">
        <div class="card">
            <div class="card-header">
                <h5 class="mb-0">新增面试</h5>
            </div>
            <div class="card-body">
                <form id="interviewForm">
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label class="form-label">简历 <span class="text-danger">*</span></label>
                            <select class="form-select" name="resumeId" required>
                                <option value="">选择简历</option>
                                <option th:each="resume : ${resumes}" 
                                        th:value="${resume.id}" 
                                        th:text="${resume.user.realName + ' - ' + resume.job.title}">
                                </option>
                            </select>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">面试官 <span class="text-danger">*</span></label>
                            <input type="text" class="form-control" name="interviewer" required>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label class="form-label">面试时间 <span class="text-danger">*</span></label>
                            <input type="datetime-local" class="form-control" name="interviewTime" required>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">面试地点 <span class="text-danger">*</span></label>
                            <input type="text" class="form-control" name="location" required>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label class="form-label">面试类型 <span class="text-danger">*</span></label>
                            <select class="form-select" name="type" required>
                                <option value="1">初试</option>
                                <option value="2">复试</option>
                            </select>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">状态 <span class="text-danger">*</span></label>
                            <select class="form-select" name="status" required>
                                <option value="1">待面试</option>
                                <option value="2">已通过</option>
                                <option value="3">未通过</option>
                            </select>
                        </div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">面试反馈</label>
                        <textarea class="form-control" name="feedback" rows="4"></textarea>
                    </div>
                    <div class="text-end">
                        <button type="button" class="btn btn-secondary" onclick="history.back()">取消</button>
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script>
        document.getElementById('interviewForm').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const formData = new FormData(this);
            const data = {};
            formData.forEach((value, key) => {
                data[key] = value;
            });

            axios.post('/interview/add', data)
                .then(response => {
                    alert('添加成功');
                    location.href = '/interview/list';
                })
                .catch(error => {
                    alert('添加失败');
                });
        });
    </script>
</body>
</html> 